package com.ly.query;

import lombok.Builder;

import java.util.Objects;

@Builder
public class ExamQuery {
    private int page;
    private int size;
    private String college;
    private String major;
    private String classCode;
    private String semester;

    // 计算偏移量
    public int getOffset() {
        return (page - 1) * size;
    }

    public ExamQuery() {
    }

    public ExamQuery(int page, int size, String college, String major, String classCode, String semester) {
        this.page = page;
        this.size = size;
        this.college = college;
        this.major = major;
        this.classCode = classCode;
        this.semester = semester;
    }

    @Override
    public String toString() {
        return "ExamQuery{" +
                "page=" + page +
                ", size=" + size +
                ", college='" + college + '\'' +
                ", major='" + major + '\'' +
                ", classCode='" + classCode + '\'' +
                ", semester='" + semester + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ExamQuery examQuery = (ExamQuery) o;
        return page == examQuery.page && size == examQuery.size && Objects.equals(college, examQuery.college) && Objects.equals(major, examQuery.major) && Objects.equals(classCode, examQuery.classCode) && Objects.equals(semester, examQuery.semester);
    }

    @Override
    public int hashCode() {
        return Objects.hash(page, size, college, major, classCode, semester);
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public String getSemester() {
        return semester;
    }

    public void setSemester(String semester) {
        this.semester = semester;
    }
}
